home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tcp_ip.arc / TCPINTRO.DOC < prev    next >
Text File  |  1987-09-22  |  95KB  |  1,770 lines

  1.  
  2.              Preface to Hedrick's
  3.            "Introduction to the Internet Protocols"
  4.                for Amateur Packet Radio
  5.  
  6.  
  7. Copyright 1987 Bdale Garbee, N3EUA.
  8. Permission to copy for non-commercial purposes granted.
  9.  
  10.  
  11. Charles Hedrick of RUTGERS, the State University of New Jersey, has written
  12. a very important document... a description of the "world of TCP/IP" that
  13. manages to be both a reasonable introduction for the non-technical or mildly
  14. technical individual, and an excellant starting point for anyone interested
  15. in learning more about the family of networking protocols commonly referred 
  16. to as "TCP/IP".
  17.  
  18. The only difficulty with this document for those who are trying to learn more
  19. about TCP/IP in the Amateur Radio "Packet" environment, is that the experience
  20. Mr. Hedrick works from is almost entirely with the wired networks common in 
  21. universities and businesses, where various computer systems are networked
  22. together using some form of wire (usually coaxial cable as in Ethernet, or
  23. fibre optic cabling as in Pronet).
  24.  
  25. The individual who is familiar with radio transmission will easily recognize 
  26. differences between the wired environment and the on-air environment.  This
  27. does not mean that the protocols are unfit for use on the air, it simply means
  28. that we need to be careful when *implementing* the protocols in software for
  29. use on the radio that we don't make assumptions that aren't valid on the air!
  30.  
  31. Mr. Hedrick mentions several protocols that can "ride on top of" TCP, such as
  32. Sun's Network File System, NFS.  Some of the applications that he talks about,
  33. including NFS, while wonderful on wired networks, are somewhat unreasonable
  34. for packet radio until or unless we have *much* higher speed modems.  Wired
  35. networks can easily run at 10 million bits per second, while packet ranges
  36. from 300 bits per second on HF, to perhaps 56 thousand bits per second on
  37. UHF.  Contemporary TCP/IP on packet may therefore not provide quite the same
  38. level of "wonderfulness" that is available to users of wired networks, but
  39. it certainly provides a dramatic improvement in potential services for the
  40. "next generation" of packet radio.
  41.  
  42. The KA9Q Internet Package is currently the most common TCP/IP implementation
  43. (if not the only one!) in use on Amateur Packet Radio.  The software supports
  44. the IBM PC and clones, and provides IP, ICMP, TCP, UDP, and ARP as basic 
  45. services, and implements the FTP, Telnet, and SMTP protocols as applications.
  46. The Package also includes a separate mail user interface program by N3EUA
  47. called BM, and software from PA0GRI for forwarding PBBS mail over TCP.  An
  48. associated set of software packages provide replacement ROM firmware for 
  49. several TNC's, allowing them to be used with the KA9Q TCP/IP Package.  At
  50. least two commercial manufacturers, AEA and Kantronics, now support the KISS
  51. protocol in their TNC's, making them useable with TCP/IP.  Various folks are
  52. busily writing additional application protocol modules, and porting the
  53. package to other machines (Macintosh, Amiga, various Unix systems, etc.).
  54.  
  55. Ok, now that we've primed you about what to watch out for, and hopefully
  56. helped you find the parts that you need to take "with a grain of salt", dig
  57. on in and read Hedrick's paper!  And when you're done, if you want to learn
  58. more about how it all works, read the documents (RFC's and IEN's) that he
  59. mentions in the references... and if you're really brave, and know or want to
  60. learn the C programming language, dig in and read the NET.EXE sources... 
  61.  
  62. Who knows?  Your life may never be the same again!
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.                              Introduction
  77.                                   to
  78.                         the Internet Protocols
  79.  
  80.  
  81.  
  82.  
  83.  
  84.                       C                       R
  85.  
  86.                               C       S
  87.                   Computer Science Facilities Group
  88.                               C       I
  89.  
  90.                       L                       S
  91.  
  92.  
  93.                                RUTGERS
  94.                   The State University of New Jersey
  95.  
  96.  
  97.  
  98.  
  99.                              3 July 1987
  100.  
  101. This is an introduction to the Internet networking protocols (TCP/IP).
  102. It  includes  a  summary  of  the  facilities  available   and   brief
  103. descriptions of the major protocols in the family.
  104.  
  105. Copyright  (C)  1987,  Charles  L. Hedrick.  Anyone may reproduce this
  106. document, in whole or in  part,  provided  that:    (1)  any  copy  or
  107. republication  of  the entire document must show Rutgers University as
  108. the source, and must include this notice; and (2)  any  other  use  of
  109. this  material  must reference this manual and Rutgers University, and
  110. the fact that the material is copyright by Charles Hedrick and is used
  111. by permission.
  112.  
  113.  
  114.  
  115. Unix is a trademark of AT&T Technologies, Inc.
  116.  
  117.  
  118.  
  119.                           Table of Contents
  120.  
  121.  
  122.    1. What is TCP/IP?                                                1
  123.    2. General description of the TCP/IP protocols                    5
  124.        2.1 The TCP level                                             7
  125.        2.2 The IP level                                             10
  126.        2.3 The Ethernet level                                       11
  127.    3. Well-known sockets and the applications layer                 12
  128.        3.1 An example application: SMTP                             15
  129.    4. Protocols other than TCP: UDP and ICMP                        17
  130.    5. Keeping track of names and information: the domain system     18
  131.    6. Routing                                                       20
  132.    7. Details about Internet addresses: subnets and broadcasting    21
  133.    8. Datagram fragmentation and reassembly                         23
  134.    9. Ethernet encapsulation: ARP                                   24
  135.    10. Getting more information                                     25
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.                                   i
  175.  
  176.  
  177.  
  178. This document is a brief introduction to TCP/IP, followed by advice on
  179. what to read for more information.  This  is  not  intended  to  be  a
  180. complete  description.    It  can  give  you  a reasonable idea of the
  181. capabilities of the protocols.  But if you need to know any details of
  182. the  technology,  you  will  want  to  read  the  standards  yourself.
  183. Throughout the text, you will find references to the standards, in the
  184. form of "RFC" or "IEN" numbers.  These are document numbers. The final
  185. section of this  document  tells  you  how  to  get  copies  of  those
  186. standards.
  187.  
  188.  
  189.  
  190. 1. What is TCP/IP?
  191.  
  192.  
  193. TCP/IP  is a set of protocols developed to allow cooperating computers
  194. to share resources across a network.  It was developed by a  community
  195. of  researchers centered around the ARPAnet.  Certainly the ARPAnet is
  196. the best-known TCP/IP network.  However as of June, 87, at  least  130
  197. different  vendors  had products that support TCP/IP, and thousands of
  198. networks of all kinds use it.
  199.  
  200. First some basic definitions.  The most accurate name for the  set  of
  201. protocols we are describing is the "Internet protocol suite".  TCP and
  202. IP are two of the protocols in this suite.  (They  will  be  described
  203. below.)    Because  TCP and IP are the best known of the protocols, it
  204. has become common to use the term TCP/IP or IP/TCP  to  refer  to  the
  205. whole  family.  It is probably not worth fighting this habit.  However
  206. this can lead to some oddities.  For example, I  find  myself  talking
  207. about  NFS as being based on TCP/IP, even though it doesn't use TCP at
  208. all.  (It does use IP.  But it  uses  an  alternative  protocol,  UDP,
  209. instead  of TCP.  All of this alphabet soup will be unscrambled in the
  210. following pages.)
  211.  
  212. The Internet is a  collection  of  networks,  including  the  Arpanet,
  213. NSFnet, regional networks such as NYsernet, local networks at a number
  214. of University and research institutions,  and  a  number  of  military
  215. networks.  The term "Internet" applies to this entire set of networks.
  216. The subset of them that is managed by the  Department  of  Defense  is
  217. referred  to  as the "DDN" (Defense Data Network).  This includes some
  218. research-oriented networks, such as  the  Arpanet,  as  well  as  more
  219. strictly  military  ones.    (Because much of the funding for Internet
  220. protocol developments is done via  the  DDN  organization,  the  terms
  221. Internet  and  DDN  can  sometimes  seem  equivalent.)    All of these
  222. networks are connected to each other.  Users can  send  messages  from
  223. any  of  them  to  any other, except where there are security or other
  224. policy restrictions on access.    Officially  speaking,  the  Internet
  225. protocol  documents  are  simply  standards  adopted  by  the Internet
  226. community for its own use.  More recently, the Department  of  Defense
  227. issued a MILSPEC definition of TCP/IP.  This was intended to be a more
  228. formal definition, appropriate for use in  purchasing  specifications.
  229. However  most  of  the  TCP/IP community continues to use the Internet
  230. standards.  The MILSPEC version is intended to be consistent with it.
  231.  
  232. Whatever it is called, TCP/IP is a family of protocols.  A few provide
  233.                                   1
  234.  
  235.  
  236.  
  237. "low-level" functions needed for many applications.  These include IP,
  238. TCP, and UDP.  (These will be described in a bit more  detail  later.)
  239. Others are protocols for doing specific tasks, e.g. transferring files
  240. between computers, sending mail, or finding out who is  logged  in  on
  241. another   computer.      Initially  TCP/IP  was  used  mostly  between
  242. minicomputers or mainframes.  These machines had their own disks,  and
  243. generally  were self-contained.  Thus the most important "traditional"
  244. TCP/IP services are:
  245.  
  246.    - file transfer.  The file transfer protocol (FTP) allows a user on
  247.      any computer to get files from another computer, or to send files
  248.      to another computer.  Security is handled by requiring  the  user
  249.      to  specify  a  user  name  and  password for the other computer.
  250.      Provisions are made for handling file transfer  between  machines
  251.      with different character set, end of line conventions, etc.  This
  252.      is not quite the same thing as more recent "network file  system"
  253.      or  "netbios"  protocols, which will be described below.  Rather,
  254.      FTP is a utility that you run any time you want to access a  file
  255.      on  another  system.    You  use  it to copy the file to your own
  256.      system.  You then work with the local copy.   (See  RFC  959  for
  257.      specifications for FTP.)
  258.  
  259.    - remote  login.    The network terminal protocol (TELNET) allows a
  260.      user to log in on any other computer on the network.  You start a
  261.      remote session by specifying a computer to connect to.  From that
  262.      time until you finish the session, anything you type is  sent  to
  263.      the  other  computer.   Note that you are really still talking to
  264.      your own computer.  But the telnet program effectively makes your
  265.      computer invisible while it is running.  Every character you type
  266.      is sent directly to the other system.  Generally, the  connection
  267.      to  the  remote  computer  behaves much like a dialup connection.
  268.      That is, the remote system will ask you to  log  in  and  give  a
  269.      password, in whatever manner it would normally ask a user who had
  270.      just dialed it up.  When you log off of the other  computer,  the
  271.      telnet  program exits, and you will find yourself talking to your
  272.      own computer.  Microcomputer implementations of telnet  generally
  273.      include  a  terminal  emulator  for some common type of terminal.
  274.      (See RFC's 854 and 855 for specifications for  telnet.    By  the
  275.      way,  the  telnet protocol should not be confused with Telenet, a
  276.      vendor of commercial network services.)
  277.  
  278.    - computer mail.  This allows you to  send  messages  to  users  on
  279.      other  computers.    Originally, people tended to use only one or
  280.      two specific computers.  They  would  maintain  "mail  files"  on
  281.      those machines.  The computer mail system is simply a way for you
  282.      to add a message to another user's mail file.    There  are  some
  283.      problems  with  this  in  an environment where microcomputers are
  284.      used.  The most serious is that a micro is  not  well  suited  to
  285.      receive  computer  mail.    When you send mail, the mail software
  286.      expects to be able  to  open  a  connection  to  the  addressee's
  287.      computer, in order to send the mail.  If this is a microcomputer,
  288.      it may be turned off, or it may be running an  application  other
  289.      than  the mail system.  For this reason, mail is normally handled
  290.      by a larger system, where it is practical to have a  mail  server
  291.      running all the time.  Microcomputer mail software then becomes a
  292.                                   2
  293.  
  294.  
  295.  
  296.      user interface that retrieves mail from the mail  server.    (See
  297.      RFC  821  and  822 for specifications for computer mail.  See RFC
  298.      937 for a protocol designed for microcomputers to use in  reading
  299.      mail from a mail server.)  
  300.  
  301. These  services  should  be  present  in any implementation of TCP/IP,
  302. except that micro-oriented implementations may  not  support  computer
  303. mail.  These traditional applications still play a very important role
  304. in TCP/IP-based networks.  However more recently,  the  way  in  which
  305. networks  are  used has been changing.  The older model of a number of
  306. large, self-sufficient computers is beginning to  change.    Now  many
  307. installations    have    several   kinds   of   computers,   including
  308. microcomputers, workstations, minicomputers, and  mainframes.    These
  309. computers  are  likely  to be configured to perform specialized tasks.
  310. Although people are still likely to work with one  specific  computer,
  311. that  computer  will  call on other systems on the net for specialized
  312. services.  This has  led  to  the  "server/client"  model  of  network
  313. services.    A server is a system that provides a specific service for
  314. the rest of the network.  A client is another system  that  uses  that
  315. service.    (Note  that the server and client need not be on different
  316. computers.  They could be  different  programs  running  on  the  same
  317. computer.)    Here  are  the  kinds  of servers typically present in a
  318. modern computer setup.  Note that these computer services can  all  be
  319. provided within the framework of TCP/IP.
  320.  
  321.    - network  file  systems.   This allows a system to access files on
  322.      another computer in a somewhat more  closely  integrated  fashion
  323.      than FTP.  A network file system provides the illusion that disks
  324.      or other devices from one system are directly connected to  other
  325.      systems.    There  is no need to use a special network utility to
  326.      access a file on another system.  Your computer simply thinks  it
  327.      has  some  extra disk drives.  These extra "virtual" drives refer
  328.      to the other system's disks.    This  capability  is  useful  for
  329.      several different purposes.  It lets you put large disks on a few
  330.      computers, but still give others access to the disk space.  Aside
  331.      from the obvious economic benefits, this allows people working on
  332.      several computers  to  share  common  files.    It  makes  system
  333.      maintenance  and  backup  easier, because you don't have to worry
  334.      about updating  and  backing  up  copies  on  lots  of  different
  335.      machines.    A  number  of  vendors  now  offer  high-performance
  336.      diskless computers.  These computers have no disk drives at  all.
  337.      They  are  entirely dependent upon disks attached to common "file
  338.      servers".   (See  RFC's  1001  and  1002  for  a  description  of
  339.      PC-oriented   NetBIOS   over   TCP.     In  the  workstation  and
  340.      minicomputer area, Sun's Network File System is more likely to be
  341.      used.    Protocol  specifications  for  it are available from Sun
  342.      Microsystems.)
  343.  
  344.    - remote printing.  This allows you to  access  printers  on  other
  345.      computers  as if they were directly attached to yours.  (The most
  346.      commonly used protocol is the remote  lineprinter  protocol  from
  347.      Berkeley  Unix.  Unfortunately, there is no protocol document for
  348.      this.  However the C code is easily obtained  from  Berkeley,  so
  349.      implementations are common.)
  350.  
  351.                                   3
  352.  
  353.  
  354.  
  355.    - remote  execution.   This allows you to request that a particular
  356.      program be run on a different computer.  This is useful when  you
  357.      can  do  most  of  your work on a small computer, but a few tasks
  358.      require the resources of a larger system.  There are a number  of
  359.      different  kinds  of remote execution.  Some operate on a command
  360.      by command basis.  That is, you request that a  specific  command
  361.      or  set  of commands should run on some specific computer.  (More
  362.      sophisticated versions will choose a system that  happens  to  be
  363.      free.)    However  there are also "remote procedure call" systems
  364.      that allow a program to  call  a  subroutine  that  will  run  on
  365.      another  computer.    (There  are  many  protocols  of this sort.
  366.      Berkeley Unix contains two servers to execute commands  remotely:
  367.      rsh  and  rexec.   The man pages describe the protocols that they
  368.      use.  The user-contributed software with Berkeley 4.3 contains  a
  369.      "distributed  shell"  that  will  distribute tasks among a set of
  370.      systems, depending upon load.  Remote procedure  call  mechanisms
  371.      have  been  a  topic  for research for a number of years, so many
  372.      organizations have implementations of such facilities.  The  most
  373.      widespread commercially-supported remote procedure call protocols
  374.      seem to be Xerox's Courier and Sun's RPC.  Protocol documents are
  375.      available  from  Xerox and Sun.  There is a public implementation
  376.      of Courier over TCP as part of the user-contributed software with
  377.      Berkeley  4.3.   An implementation of RPC was posted to Usenet by
  378.      Sun, and also appears as part of  the  user-contributed  software
  379.      with Berkeley 4.3.)
  380.  
  381.    - name  servers.    In  large  installations, there are a number of
  382.      different collections of names that have to  be  managed.    This
  383.      includes  users  and their passwords, names and network addresses
  384.      for computers, and accounts.  It becomes  very  tedious  to  keep
  385.      this data up to date on all of the computers.  Thus the databases
  386.      are kept on a small number of systems.  Other systems access  the
  387.      data over the network.  (RFC 822 and 823 describe the name server
  388.      protocol used to keep track of host names and Internet  addresses
  389.      on  the  Internet.    This  is  now a required part of any TCP/IP
  390.      implementation.  IEN 116 describes an older name server  protocol
  391.      that is used by a few terminal servers and other products to look
  392.      up host names.  Sun's  Yellow  Pages  system  is  designed  as  a
  393.      general  mechanism to handle user names, file sharing groups, and
  394.      other databases commonly used by Unix  systems.    It  is  widely
  395.      available  commercially.    Its  protocol definition is available
  396.      from Sun.)
  397.  
  398.    - terminal servers.  Many installations no longer connect terminals
  399.      directly  to  computers.    Instead they connect them to terminal
  400.      servers.  A terminal server is simply a small computer that  only
  401.      knows  how  to  run  telnet  (or some other protocol to do remote
  402.      login).  If your terminal is  connected  to  one  of  these,  you
  403.      simply  type the name of a computer, and you are connected to it.
  404.      Generally it is possible to have active connections to more  than
  405.      one  computer  at  the  same time.  The terminal server will have
  406.      provisions to switch between connections rapidly, and  to  notify
  407.      you  when  output  is  waiting for another connection.  (Terminal
  408.      servers use the telnet protocol, already mentioned.  However  any
  409.      real terminal server will also have to support name service and a
  410.                                   4
  411.  
  412.  
  413.  
  414.      number of other protocols.)
  415.  
  416.    - network-oriented  window  systems.      Until   recently,   high-
  417.      performance  graphics  programs had to execute on a computer that
  418.      had  a  bit-mapped  graphics  screen  directly  attached  to  it.
  419.      Network  window  systems  allow  a  program to use a display on a
  420.      different computer.  Full-scale network window systems provide an
  421.      interface  that  lets you distribute jobs to the systems that are
  422.      best  suited  to  handle  them,  but  still  give  you  a  single
  423.      graphically-based  user  interface.  (The most widely-implemented
  424.      window system is X. A  protocol  description  is  available  from
  425.      MIT's  Project  Athena.  A reference implementation is publically
  426.      available from MIT.  A number  of  vendors  are  also  supporting
  427.      NeWS,  a window system defined by Sun.  Both of these systems are
  428.      designed to use TCP/IP.)  
  429.  
  430. Note that some of the  protocols  described  above  were  designed  by
  431. Berkeley,  Sun,  or other organizations.  Thus they are not officially
  432. part of the Internet protocol suite.   However  they  are  implemented
  433. using  TCP/IP, just as normal TCP/IP application protocols are.  Since
  434. the protocol definitions are not  considered  proprietary,  and  since
  435. commercially-support  implementations  are  widely  available,  it  is
  436. reasonable to think of these protocols as being  effectively  part  of
  437. the  Internet  suite.   Note that the list above is simply a sample of
  438. the sort of services  available  through  TCP/IP.    However  it  does
  439. contain   the  majority  of  the  "major"  applications.    The  other
  440. commonly-used protocols tend to be specialized facilities for  getting
  441. information  of  various  kinds, such as who is logged in, the time of
  442. day, etc.  However if you need a facility that is not listed here,  we
  443. encourage  you  to  look  through  the  current  edition  of  Internet
  444. Protocols (currently RFC 1011),  which  lists  all  of  the  available
  445. protocols,   and   also   to   look   at  some  of  the  major  TCP/IP
  446. implementations to see what various vendors have added.
  447.  
  448.  
  449.  
  450. 2. General description of the TCP/IP protocols
  451.  
  452.  
  453. TCP/IP is a layered set of protocols.  In  order  to  understand  what
  454. this  means,  it is useful to look at an example.  A typical situation
  455. is sending mail.  First, there is a protocol for mail.  This defines a
  456. set  of  commands which one machine sends to another, e.g. commands to
  457. specify who the sender of the message is, who it is being sent to, and
  458. then  the  text  of  the  message.  However this protocol assumes that
  459. there is a way to communicate  reliably  between  the  two  computers.
  460. Mail,  like  other  application  protocols,  simply  defines  a set of
  461. commands and messages to be sent.  It is designed to be used  together
  462. with  TCP and IP. TCP is responsible for making sure that the commands
  463. get through to the other end.  It keeps track of  what  is  sent,  and
  464. retransmitts anything that did not get through.  If any message is too
  465. large for one datagram, e.g. the text of the mail, TCP will  split  it
  466. up  into  several  datagrams,  and  make  sure  that  they  all arrive
  467. correctly.  Since these functions are needed  for  many  applications,
  468. they are put together into a separate protocol, rather than being part
  469.                                   5
  470.  
  471.  
  472.  
  473. of the specifications for sending mail.   You  can  think  of  TCP  as
  474. forming a library of routines that applications can use when they need
  475. reliable network communications with another computer.  Similarly, TCP
  476. calls  on the services of IP.  Although the services that TCP supplies
  477. are needed by  many  applications,  there  are  still  some  kinds  of
  478. applications  that  don't  need them.  However there are some services
  479. that every application needs.  So these services are put together into
  480. IP.    As  with TCP, you can think of IP as a library of routines that
  481. TCP calls on, but which is also available to applications  that  don't
  482. use  TCP.    This  strategy  of building several levels of protocol is
  483. called "layering".  We think of  the  applications  programs  such  as
  484. mail,  TCP, and IP, as being separate "layers", each of which calls on
  485. the services of the layer below it.   Generally,  TCP/IP  applications
  486. use 4 layers:
  487.  
  488.    - an application protocol such as mail
  489.  
  490.    - a  protocol  such  as  TCP  that  provides  services need by many
  491.      applications
  492.  
  493.    - IP, which provides the basic  service  of  getting  datagrams  to
  494.      their destination
  495.  
  496.    - the  protocols  needed to manage a specific physical medium, such
  497.      as Ethernet or a point to point line.  
  498.  
  499. TCP/IP is based on the "catenet model".  (This is  described  in  more
  500. detail  in  IEN 48.)  This model assumes that there are a large number
  501. of independent networks connected together  by  gateways.    The  user
  502. should  be able to access computers or other resources on any of these
  503. networks.   Datagrams  will  often  pass  through  a  dozen  different
  504. networks  before  getting  to  their  final  destination.  The routing
  505. needed to accomplish this should be completely invisible to the  user.
  506. As  far  as  the  user  is concerned, all he needs to know in order to
  507. access another system is an "Internet address".  This  is  an  address
  508. that looks like 128.6.4.194.  It is actually a 32-bit number.  However
  509. it is normally written as 4 decimal numbers, each representing 8  bits
  510. of  the  address.  (The term "octet" is used by Internet documentation
  511. for such 8-bit chunks.  The term "byte" is not used, because TCP/IP is
  512. supported  by  some computers that have byte sizes other than 8 bits.)
  513. Generally the structure of the  address  gives  you  some  information
  514. about  how  to  get  to  the  system.  For example, 128.6 is a network
  515. number assigned by a central authority to Rutgers University.  Rutgers
  516. uses  the  next  octet  to  indicate  which of the campus Ethernets is
  517. involved.  128.6.4 happens to be an  Ethernet  used  by  the  Computer
  518. Science  Department.    The last octet allows for up to 254 systems on
  519. each Ethernet.  (It is 254 because 0 and  255  are  not  allowed,  for
  520. reasons  that  will  be  discussed  later.)  Note that 128.6.4.194 and
  521. 128.6.5.194 would be different systems.  The structure of an  Internet
  522. address is described in a bit more detail later.
  523.  
  524. Of  course  we  normally  refer  to  systems  by  name, rather than by
  525. Internet address.  When we specify a name, the network software  looks
  526. it  up  in  a  database,  and comes up with the corresponding Internet
  527. address.  Most of the network software deals strictly in terms of  the
  528.                                   6
  529.  
  530.  
  531.  
  532. address.  (RFC 882 describes the name server technology used to handle
  533. this lookup.)
  534.  
  535. TCP/IP is  built  on  "connectionless"  technology.    Information  is
  536. transfered  as  a sequence of "datagrams".  A datagram is a collection
  537. of data that is sent as a single message.  Each of these datagrams  is
  538. sent  through  the network individually.  There are provisions to open
  539. connections (i.e.  to start a conversation that will continue for some
  540. time).    However at some level, information from those connections is
  541. broken up into datagrams, and  those  datagrams  are  treated  by  the
  542. network  as  completely  separate.    For example, suppose you want to
  543. transfer a 15000 octet file.  Most networks can't handle a 15000 octet
  544. datagram.   So the protocols will break this up into something like 30
  545. 500-octet datagrams.  Each of these datagrams  will  be  sent  to  the
  546. other  end.    At  that point, they will be put back together into the
  547. 15000-octet file.  However while those datagrams are in  transit,  the
  548. network doesn't know that there is any connection between them.  It is
  549. perfectly possible  that  datagram  14  will  actually  arrive  before
  550. datagram  13.    It is also possible that somewhere in the network, an
  551. error will occur, and some datagram won't get through at all.  In that
  552. case, that datagram has to be sent again.
  553.  
  554. Note  by  the way that the terms "datagram" and "packet" often seem to
  555. be nearly interchangable.  Technically, datagram is the right word  to
  556. use  when  describing  TCP/IP.  A datagram is a unit of data, which is
  557. what the protocols deal with.  A packet is a physical thing, appearing
  558. on an Ethernet or some wire.  In most cases a packet simply contains a
  559. datagram, so there is  very  little  difference.    However  they  can
  560. differ.  When TCP/IP is used on top of X.25, the X.25 interface breaks
  561. the datagrams up into 128-byte packets.   This  is  invisible  to  IP,
  562. because  the  packets  are put back together into a single datagram at
  563. the other end before being processed by TCP/IP.  So in this case,  one
  564. IP  datagram  would  be carried by several packets.  However with most
  565. media, there are efficiency advantages to  sending  one  datagram  per
  566. packet, and so the distinction tends to vanish.
  567.  
  568.  
  569.  
  570. 2.1 The TCP level
  571.  
  572.  
  573. Two separate protocols are involved in handling TCP/IP datagrams.  TCP
  574. (the "transmission control protocol") is responsible for  breaking  up
  575. the  message  into  datagrams,  reassembling  them  at  the other end,
  576. resending anything that gets lost, and  putting  things  back  in  the
  577. right  order.  IP (the "internet protocol") is responsible for routing
  578. individual datagrams.  It may seem like TCP is  doing  all  the  work.
  579. And  in  small networks that is true.  However in the Internet, simply
  580. getting a datagram to its  destination  can  be  a  complex  job.    A
  581. connection  may require the datagram to go through several networks at
  582. Rutgers, a serial line to the John von Neuman Supercomputer Center,  a
  583. couple  of Ethernets there, a series of 56Kbaud phone lines to another
  584. NSFnet site, and more Ethernets on another campus.  Keeping  track  of
  585. the  routes  to all of the destinations and handling incompatibilities
  586. among different transport media turns out to be a complex job.    Note
  587.                                   7
  588.  
  589.  
  590.  
  591. that  the  interface  between TCP and IP is fairly simple.  TCP simply
  592. hands IP a datagram with a destination.   IP  doesn't  know  how  this
  593. datagram relates to any datagram before it or after it.
  594.  
  595. It  may  have occurred to you that something is missing here.  We have
  596. talked about Internet addresses, but not about how you keep  track  of
  597. multiple  connections  to  a given system.  Clearly it isn't enough to
  598. get a datagram to the right  destination.    TCP  has  to  know  which
  599. connection  this  datagram  is  part  of.  This task is referred to as
  600. "demultiplexing."  In fact, there are several levels of demultiplexing
  601. going  on in TCP/IP.  The information needed to do this demultiplexing
  602. is contained in a series of "headers".  A header is simply a few extra
  603. octets  tacked  onto  the  beginning of a datagram by some protocol in
  604. order to keep track of it.  It's a lot like putting a letter  into  an
  605. envelope  and  putting  an  address  on  the  outside of the envelope.
  606. Except with modern networks it happens several times.  It's  like  you
  607. put the letter into a little envelope, your secretary puts that into a
  608. somewhat bigger envelope, the campus mail center  puts  that  envelope
  609. into a still bigger one, etc.  Here is an overview of the headers that
  610. get stuck on a message that passes through a typical TCP/IP network:
  611.  
  612. We start with a single data stream, say a file you are trying to  send
  613. to some other computer:  
  614.  
  615.    ......................................................
  616.  
  617. TCP  breaks  it  up into manageable chunks.  (In order to do this, TCP
  618. has to know how large a datagram your network can handle.    Actually,
  619. the TCP's at each end say how big a datagram they can handle, and then
  620. they pick the smallest size.)  
  621.  
  622.    ....   ....   ....   ....   ....   ....   ....   ....
  623.  
  624. TCP puts a header at the front of each datagram.  This header actually
  625. contains  at least 20 octets, but the most important ones are a source
  626. and destination "port number" and  a  "sequence  number".    The  port
  627. numbers  are used to keep track of different conversations.  Suppose 3
  628. different people are transferring files.  Your TCP might allocate port
  629. numbers 1000, 1001, and 1002 to these transfers.  When you are sending
  630. a datagram, this becomes the "source" port number, since you  are  the
  631. source  of  the  datagram.    Of  course  the TCP at the other end has
  632. assigned a port number of its own for the conversation.  Your TCP  has
  633. to  know the port number used by the other end as well.  (It finds out
  634. when the connection starts, as we will explain below.)  It  puts  this
  635. in  the  "destination" port field.  Of course if the other end sends a
  636. datagram back to you, the source and destination port numbers will  be
  637. reversed,  since  then  it  will  be  the  source  and you will be the
  638. destination.  Each datagram has a sequence number.  This  is  used  so
  639. that  the  other  end  can make sure that it gets the datagrams in the
  640. right  order,  and  that  it  hasn't  missed  any.    (See   the   TCP
  641. specification for details.)  TCP doesn't number the datagrams, but the
  642. octets.  So if there are 500 octets of  data  in  each  datagram,  the
  643. first datagram might be numbered 0, the second 500, the next 1000, the
  644. next 1500, etc.  Finally, I will mention the  Checksum.    This  is  a
  645. number  that  is  computed by adding up all the octets in the datagram
  646.                                   8
  647.  
  648.  
  649.  
  650. (more or less - see the TCP spec).  The result is put in  the  header.
  651. TCP  at  the other end computes the checksum again.  If they disagree,
  652. then something bad happened to the datagram in transmission, and it is
  653. thrown away.  So here's what the datagram looks like now.
  654.  
  655.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  656.     |          Source Port          |       Destination Port        |
  657.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  658.     |                        Sequence Number                        |
  659.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  660.     |                    Acknowledgment Number                      |
  661.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  662.     |  Data |           |U|A|P|R|S|F|                               |
  663.     | Offset| Reserved  |R|C|S|S|Y|I|            Window             |
  664.     |       |           |G|K|H|T|N|N|                               |
  665.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  666.     |           Checksum            |         Urgent Pointer        |
  667.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  668.     |   your data ... next 500 octets                               |
  669.     |   ......                                                      |
  670.  
  671. If  we abbreviate the TCP header as "T", the whole file now looks like
  672. this:
  673.  
  674.    T....   T....   T....   T....   T....   T....   T....
  675.  
  676. You will note that there are items in  the  header  that  I  have  not
  677. described  above.    They  are  generally  involved  with managing the
  678. connection.  In order to make sure the datagram  has  arrived  at  its
  679. destination,  the  recipient  has  to  send back an "acknowledgement".
  680. This is a datagram whose "Acknowledgement number" field is filled  in.
  681. For  example,  sending  a  packet  with  an  acknowledgement  of  1500
  682. indicates that you have received all the data up to octet number 1500.
  683. If  the  sender  doesn't  get  an  acknowledgement within a reasonable
  684. amount of time, it sends the data  again.    The  window  is  used  to
  685. control  how  much  data can be in transit at any one time.  It is not
  686. practical to wait for each datagram to be acknowledged before  sending
  687. the  next  one.    That would slow things down too much.  On the other
  688. hand, you can't just keep sending, or a fast  computer  might  overrun
  689. the  capacity  of  a slow one to absorb data.  Thus each end indicates
  690. how much new data it is currently prepared to absorb  by  putting  the
  691. number  of  octets  in  its  "Window" field.  As the computer receives
  692. data, the amount of space left in its window decreases.  When it  goes
  693. to  zero, the sender has to stop.  As the receiver processes the data,
  694. it increases its window, indicating that it is ready  to  accept  more
  695. data.  Often the same datagram can be used to acknowledge receipt of a
  696. set of data and to give permission for  additional  new  data  (by  an
  697. updated  window).  The "Urgent" field allows one end to tell the other
  698. to skip ahead in its processing to a particular octet.  This is  often
  699. useful  for  handling asynchronous events, for example when you type a
  700. control character or other command that interrupts output.  The  other
  701. fields are beyond the scope of this document.
  702.  
  703.  
  704.  
  705.                                   9
  706.  
  707.  
  708.  
  709. 2.2 The IP level
  710.  
  711.  
  712. TCP  sends each of these datagrams to IP.  Of course it has to tell IP
  713. the Internet address of the computer at the other end.  Note that this
  714. is  all  IP  is concerned about.  It doesn't care about what is in the
  715. datagram, or even in the TCP header.  IP's job is  simply  to  find  a
  716. route for the datagram and get it to the other end.  In order to allow
  717. gateways or other intermediate systems to  forward  the  datagram,  it
  718. adds  its  own  header.  The main things in this header are the source
  719. and destination Internet address (32-bit addresses, like 128.6.4.194),
  720. the  protocol  number,  and  another  checksum.    The source Internet
  721. address is simply the address of your machine.  (This is necessary  so
  722. the  other  end  knows where the datagram came from.)  The destination
  723. Internet address is the address  of  the  other  machine.    (This  is
  724. necessary  so  any  gateways  in  the  middle  know where you want the
  725. datagram to go.)  The protocol number tells IP at  the  other  end  to
  726. send  the  datagram  to TCP.  Although most IP traffic uses TCP, there
  727. are other protocols that can use IP, so you  have  to  tell  IP  which
  728. protocol  to send the datagram to.  Finally, the checksum allows IP at
  729. the other end to verify that the header  wasn't  damaged  in  transit.
  730. Note  that TCP and IP have separate checksums.  IP needs to be able to
  731. verify that the header didn't get damaged in transit, or it could send
  732. a  message to the wrong place.  For reasons not worth discussing here,
  733. it is both more efficient and safer to have  TCP  compute  a  separate
  734. checksum  for  the  TCP  header  and  data.  Once IP has tacked on its
  735. header, here's what the message looks like:
  736.  
  737.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  738.     |Version|  IHL  |Type of Service|          Total Length         |
  739.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  740.     |         Identification        |Flags|      Fragment Offset    |
  741.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  742.     |  Time to Live |    Protocol   |         Header Checksum       |
  743.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  744.     |                       Source Address                          |
  745.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  746.     |                    Destination Address                        |
  747.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  748.     |  TCP header, then your data ......                            |
  749.     |                                                               |
  750.  
  751. If we represent the IP header by an "I",  your  file  now  looks  like
  752. this:  
  753.  
  754.    IT....   IT....   IT....   IT....   IT....   IT....   IT....
  755.  
  756. Again,  the  header contains some additional fields that have not been
  757. discussed.  Most of them are beyond the scope of this document.    The
  758. flags  and fragment offset are used to keep track of the pieces when a
  759. datagram has to be split up.   This  can  happen  when  datagrams  are
  760. forwarded through a network for which they are too big.  (This will be
  761. discussed a bit more below.)  The time to live is  a  number  that  is
  762. decremented  whenever  the  datagram passes through a system.  When it
  763. goes to zero, the datagram is discarded.  This is done in case a  loop
  764.                                   10
  765.  
  766.  
  767.  
  768. develops  in the system somehow.  Of course this should be impossible,
  769. but  well-designed  networks  are  built  to  cope  with  "impossible"
  770. conditions.
  771.  
  772. At this point, it's possible that no more headers are needed.  If your
  773. computer happens to have a direct phone  line  connecting  it  to  the
  774. destination  computer,  or  to  a  gateway,  it  may  simply  send the
  775. datagrams out on the line (though likely a synchronous  protocol  such
  776. as  HDLC  would be used, and it would add at least a few octets at the
  777. beginning and end).
  778.  
  779.  
  780.  
  781. 2.3 The Ethernet level
  782.  
  783.  
  784. However most of our networks these days use Ethernet.  So now we  have
  785. to  describe  Ethernet's headers.  Unfortunately, Ethernet has its own
  786. addresses.  The people who designed Ethernet wanted to make sure  that
  787. no  two  machines  would  end  up  with  the  same  Ethernet  address.
  788. Furthermore, they  didn't  want  the  user  to  have  to  worry  about
  789. assigning  addresses.    So  each  Ethernet  controller  comes with an
  790. address builtin from the factory.  In order to  make  sure  that  they
  791. would  never have to reuse addresses, the Ethernet designers allocated
  792. 48 bits for the Ethernet address.  People who make Ethernet  equipment
  793. have  to  register  with  a  central  authority, to make sure that the
  794. numbers they assign don't overlap any other manufacturer.  Ethernet is
  795. a "broadcast medium".  That is, it is in effect like an old party line
  796. telephone.  When you send a packet out on the Ethernet, every  machine
  797. on  the  network sees the packet.  So something is needed to make sure
  798. that the right machine gets it.  As you might guess, this involves the
  799. Ethernet  header.    Every  Ethernet packet has a 14-octet header that
  800. includes the source and destination Ethernet address, and a type code.
  801. Each machine is supposed to pay attention only to packets with its own
  802. Ethernet address in the destination field.  (It's  perfectly  possible
  803. to  cheat,  which  is  one reason that Ethernet communications are not
  804. terribly secure.)  Note  that  there  is  no  connection  between  the
  805. Ethernet address and the Internet address.  Each machine has to have a
  806. table of what Ethernet address corresponds to what  Internet  address.
  807. (We  will  describe  how  this  table is constructed a bit later.)  In
  808. addition to the addresses, the header contains a type code.  The  type
  809. code is to allow for several different protocol families to be used on
  810. the same network.  So you can use TCP/IP, DECnet, Xerox  NS,  etc.  at
  811. the  same  time.   Each of them will put a different value in the type
  812. field.  Finally,  there  is  a  checksum.    The  Ethernet  controller
  813. computes a checksum of the entire packet.  When the other end receives
  814. the packet, it recomputes the checksum, and throws the packet away  if
  815. the  answer  disagrees  with the original.  The checksum is put on the
  816. end of the packet, not in the header.  The final result is  that  your
  817. message looks like this:
  818.  
  819.  
  820.  
  821.  
  822.  
  823.                                   11
  824.  
  825.  
  826.  
  827.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  828.     |       Ethernet destination address (first 32 bits)            |
  829.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  830.     | Ethernet dest (last 16 bits)  |Ethernet source (first 16 bits)|
  831.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  832.     |       Ethernet source address (last 32 bits)                  |
  833.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  834.     |        Type code              |
  835.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  836.     |  IP header, then TCP header, then your data                   |
  837.     |                                                               |
  838.         ...
  839.     |                                                               |
  840.     |   end of your data                                            |
  841.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  842.     |                       Ethernet Checksum                       |
  843.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  844.  
  845. If  we  represent  the  Ethernet  header  with  "E",  and the Ethernet
  846. checksum with "C", your file now looks like this:  
  847.  
  848.    EIT....C   EIT....C   EIT....C   EIT....C   EIT....C
  849.  
  850. When these packets are received by the other end, of  course  all  the
  851. headers  are  removed.    The  Ethernet interface removes the Ethernet
  852. header and the checksum.  It looks at the type code.  Since  the  type
  853. code  is the one assigned to IP, the Ethernet device driver passes the
  854. datagram up to IP.  IP removes the IP header.   It  looks  at  the  IP
  855. protocol  field.    Since  the  protocol  type  is  TCP, it passes the
  856. datagram up to TCP.  TCP now looks at the sequence number.    It  uses
  857. the  sequence  numbers  and  other  information  to  combine  all  the
  858. datagrams into the original file.
  859.  
  860. The ends our initial summary of TCP/IP.  There are still some  crucial
  861. concepts we haven't gotten to, so we'll now go back and add details in
  862. several areas.  (For detailed descriptions of the items discussed here
  863. see,  RFC  793  for  TCP,  RFC  791  for IP, and RFC's 894 and 826 for
  864. sending IP over Ethernet.)
  865.  
  866.  
  867.  
  868. 3. Well-known sockets and the applications layer
  869.  
  870.  
  871. So far, we have described how a stream  of  data  is  broken  up  into
  872. datagrams,  sent  to another computer, and put back together.  However
  873. something more is needed  in  order  to  accomplish  anything  useful.
  874. There  has  to  be  a  way for you to open a connection to a specified
  875. computer, log into it, tell it what file you  want,  and  control  the
  876. transmission  of  the  file.   (If you have a different application in
  877. mind, e.g. computer mail, some analogous protocol is needed.)  This is
  878. done  by  "application  protocols".  The application protocols run "on
  879. top" of TCP/IP.  That is, when they want to send a message, they  give
  880. the  message  to  TCP.   TCP makes sure it gets delivered to the other
  881. end.  Because TCP and IP take care of all the networking details,  the
  882.                                   12
  883.  
  884.  
  885.  
  886. applications  protocols can treat a network connection as if it were a
  887. simple byte stream, like a terminal or phone line.
  888.  
  889. Before going into more details about applications programs, we have to
  890. describe how you find an application.  Suppose you want to send a file
  891. to a computer whose Internet address  is  128.6.4.7.    To  start  the
  892. process,  you  need  more than just the Internet address.  You have to
  893. connect to the FTP server at the  other  end.    In  general,  network
  894. programs  are  specialized  for a specific set of tasks.  Most systems
  895. have separate programs  to  handle  file  transfers,  remote  terminal
  896. logins, mail, etc.  When you connect to 128.6.4.7, you have to specify
  897. that you want to talk to the FTP server.    This  is  done  by  having
  898. "well-known  sockets"  for  each  server.    Recall that TCP uses port
  899. numbers to keep track of  individual  conversations.    User  programs
  900. normally  use more or less random port numbers.  However specific port
  901. numbers are assigned to the programs that sit  waiting  for  requests.
  902. For  example,  if  you  want  to send a file, you will start a program
  903. called "ftp".  It will open a connection using some random number, say
  904. 1234,  for  the  port number on its end.  However it will specify port
  905. number 21 for the other end.  This is the official port number for the
  906. FTP server.  Note that there are two different programs involved.  You
  907. run ftp on your side.  This is a program designed to  accept  commands
  908. from  your  terminal  and  pass them on to the other end.  The program
  909. that you talk to on the other machine  is  the  FTP  server.    It  is
  910. designed  to  accept commands from the network connection, rather than
  911. an interactive terminal.  There is no need for your program to  use  a
  912. well-known  socket  number  for  itself.  Nobody is trying to find it.
  913. However the servers have to have well-known numbers,  so  that  people
  914. can  open  connections  to  them and start sending them commands.  The
  915. official  port  numbers  for  each  program  are  given  in  "Assigned
  916. Numbers".
  917.  
  918. Note  that  a  connection is actually described by a set of 4 numbers:
  919. the Internet address at each end, and the TCP port number at each end.
  920. Every  datagram  has  all  four of those numbers in it.  (The Internet
  921. addresses are in the IP header, and the TCP port numbers  are  in  the
  922. TCP header.)  In order to keep things straight, no two connections can
  923. have the same set of numbers.  However it is enough for any one number
  924. to  be  different.    For  example,  it  is perfectly possible for two
  925. different users on a machine to be sending files  to  the  same  other
  926. machine.    This  could  result  in  connections  with  the  following
  927. parameters:
  928.  
  929.                    Internet addresses         TCP ports
  930.     connection 1  128.6.4.194, 128.6.4.7      1234, 21
  931.     connection 2  128.6.4.194, 128.6.4.7      1235, 21
  932.  
  933. Since the same machines are involved, the Internet addresses  are  the
  934. same.    Since  they  are  both  doing  file transfers, one end of the
  935. connection involves the well-known port number  for  FTP.    The  only
  936. thing  that  differs is the port number for the program that the users
  937. are running.  That's enough of a difference.  Generally, at least  one
  938. end  of  the  connection asks the network software to assign it a port
  939. number that is guaranteed to be unique.   Normally,  it's  the  user's
  940. end, since the server has to use a well-known number.
  941.                                   13
  942.  
  943.  
  944.  
  945.  
  946. Now  that  we  know  how  to  open  connections, let's get back to the
  947. applications programs.  As mentioned earlier, once TCP  has  opened  a
  948. connection,  we  have  something  that might as well be a simple wire.
  949. All the hard parts are handled by TCP and IP.  However we  still  need
  950. some  agreement  as  to  what we send over this connection.  In effect
  951. this is simply an agreement on what set of  commands  the  application
  952. will  understand,  and  the  format  in  which  they  are  to be sent.
  953. Generally, what is sent is a combination of commands and data.    They
  954. use  context  to  differentiate.  For example, the mail protocol works
  955. like this: Your mail program opens a connection to the mail server  at
  956. the  other end.  Your program gives it your machine's name, the sender
  957. of the message, and the recipients you want it sent to.  It then sends
  958. a  command saying that it is starting the message.  At that point, the
  959. other end  stops  treating  what  it  sees  as  commands,  and  starts
  960. accepting  the  message.  Your end then starts sending the text of the
  961. message.  At the end of the message, a special mark is sent (a dot  in
  962. the first column).  After that, both ends understand that your program
  963. is again sending commands.  This is the simplest way to do things, and
  964. the one that most applications use.
  965.  
  966. File  transfer  is  somewhat more complex.  The file transfer protocol
  967. involves two different connections.  It starts  out  just  like  mail.
  968. The user's program sends commands like "log me in as this user", "here
  969. is my password", "send me the file with this name".  However once  the
  970. command  to  send  data is sent, a second connection is opened for the
  971. data itself.  It would certainly be possible to send the data  on  the
  972. same  connection,  as  mail does.  However file transfers often take a
  973. long time.  The designers of the  file  transfer  protocol  wanted  to
  974. allow  the  user  to  continue  issuing commands while the transfer is
  975. going on.  For example, the user might make an inquiry,  or  he  might
  976. abort  the  transfer.    Thus  the designers felt it was best to use a
  977. separate connection for  the  data  and  leave  the  original  command
  978. connection  for  commands.    (It  is  also  possible  to open command
  979. connections to two different computers, and tell them to send  a  file
  980. from  one  to  the other.  In that case, the data couldn't go over the
  981. command connection.)
  982.  
  983. Remote terminal connections use another mechanism still.   For  remote
  984. logins,  there  is just one connection.  It normally sends data.  When
  985. it is necessary to send a command (e.g. to set the terminal type or to
  986. change  some  mode),  a special character is used to indicate that the
  987. next character is a command.  If the user happens to type that special
  988. character as data, two of them are sent.
  989.  
  990. We  are  not  going to describe the application protocols in detail in
  991. this document.  It's better to read the RFC's yourself.  However there
  992. are  a  couple of common conventions used by applications that will be
  993. described here.  First, the common network representation:  TCP/IP  is
  994. intended  to  be  usable  on  any  computer.    Unfortunately, not all
  995. computers agree on how data is represented.  There are differences  in
  996. character  codes  (ASCII  vs.  EBCDIC),  in  end  of  line conventions
  997. (carriage return, line feed, or a representation using counts), and in
  998. whether  terminals expect characters to be sent individually or a line
  999. at a time.   In  order  to  allow  computers  of  different  kinds  to
  1000. communicate,   each   applications   protocol   defines   a   standard
  1001.                                   14
  1002.  
  1003.  
  1004.  
  1005. representation.    Note  that  TCP  and  IP  do  not  care  about  the
  1006. representation.    TCP  simply  sends octets.  However the programs at
  1007. both ends have to agree on how the octets are to be interpreted.   The
  1008. RFC  for  each  application  specifies the standard representation for
  1009. that application.  Normally it  is  "net  ASCII".    This  uses  ASCII
  1010. characters,  with end of line denoted by a carriage return followed by
  1011. a line feed.  For remote login,  there  is  also  a  definition  of  a
  1012. "standard terminal", which turns out to be a half-duplex terminal with
  1013. echoing happening on the local machine.  Most applications  also  make
  1014. provisions  for  the  two  computers to agree on other representations
  1015. that they may find more convenient.  For example, PDP-10's have 36-bit
  1016. words.    There  is a way that two PDP-10's can agree to send a 36-bit
  1017. binary file.  Similarly, two systems that prefer full-duplex  terminal
  1018. conversations  can  agree  on  that.    However each application has a
  1019. standard representation, which every machine must support.
  1020.  
  1021.  
  1022.  
  1023. 3.1 An example application: SMTP
  1024.  
  1025.  
  1026. In order to give a bit better idea what is involved in the application
  1027. protocols,  I'm  going  to  show an example of SMTP, which is the mail
  1028. protocol.  (SMTP is "simple mail transfer protocol.)  We assume that a
  1029. computer called TOPAZ.RUTGERS.EDU wants to send the following message.
  1030.  
  1031.   Date: Sat, 27 Jun 87 13:26:31 EDT
  1032.   From: hedrick@topaz.rutgers.edu
  1033.   To: levy@red.rutgers.edu
  1034.   Subject: meeting
  1035.  
  1036.   Let's get together Monday at 1pm.
  1037.  
  1038. First,  note  that the format of the message itself is described by an
  1039. Internet standard (RFC 822).  The standard specifies the fact that the
  1040. message  must be transmitted as net ASCII (i.e. it must be ASCII, with
  1041. carriage return/linefeed to delimit lines).   It  also  describes  the
  1042. general  structure, as a group of header lines, then a blank line, and
  1043. then the body of the message.  Finally, it describes the syntax of the
  1044. header  lines in detail.  Generally they consist of a keyword and then
  1045. a value.
  1046.  
  1047. Note  that  the  addressee  is  indicated   as   LEVY@RED.RUTGERS.EDU.
  1048. Initially,  addresses were simply "person at machine".  However recent
  1049. standards have made things more flexible.  There  are  now  provisions
  1050. for  systems  to handle other systems' mail.  This can allow automatic
  1051. forwarding on behalf of computers not connected to the Internet.    It
  1052. can be used to direct mail for a number of systems to one central mail
  1053. server.  Indeed there is no requirement that an actual computer by the
  1054. name  of RED.RUTGERS.EDU even exist.  The name servers could be set up
  1055. so that you mail to department names, and each  department's  mail  is
  1056. routed  automatically to an appropriate computer.  It is also possible
  1057. that the part before the @ is something other than a user name.  It is
  1058. possible  for  programs  to be set up to process mail.  There are also
  1059. provisions  to  handle  mailing  lists,  and  generic  names  such  as
  1060.                                   15
  1061.  
  1062.  
  1063.  
  1064. "postmaster" or "operator".
  1065.  
  1066. The  way  the  message is to be sent to another system is described by
  1067. RFC's 821 and 974.  The program that is going to be doing the  sending
  1068. asks  the  name server several queries to determine where to route the
  1069. message.  The first query is to find out which  machines  handle  mail
  1070. for  the  name RED.RUTGERS.EDU.  In this case, the server replies that
  1071. RED.RUTGERS.EDU handles its own mail.  The program then asks  for  the
  1072. address of RED.RUTGERS.EDU, which is 128.6.4.2.  Then the mail program
  1073. opens a TCP connection to port 25  on  128.6.4.2.    Port  25  is  the
  1074. well-known  socket  used  for receiving mail.  Once this connection is
  1075. established, the mail program starts sending  commands.    Here  is  a
  1076. typical  conversation.  Each line is labelled as to whether it is from
  1077. TOPAZ or RED.  Note that TOPAZ initiated the connection:
  1078.  
  1079.     RED    220 RED.RUTGERS.EDU SMTP Service at 29 Jun 87 05:17:18 EDT
  1080.     TOPAZ  HELO topaz.rutgers.edu
  1081.     RED    250 RED.RUTGERS.EDU - Hello, TOPAZ.RUTGERS.EDU
  1082.     TOPAZ  MAIL From:<hedrick@topaz.rutgers.edu>
  1083.     RED    250 MAIL accepted
  1084.     TOPAZ  RCPT To:<levy@red.rutgers.edu>
  1085.     RED    250 Recipient accepted
  1086.     TOPAZ  DATA
  1087.     RED    354 Start mail input; end with <CRLF>.<CRLF>
  1088.     TOPAZ  Date: Sat, 27 Jun 87 13:26:31 EDT
  1089.     TOPAZ  From: hedrick@topaz.rutgers.edu
  1090.     TOPAZ  To: levy@red.rutgers.edu
  1091.     TOPAZ  Subject: meeting
  1092.     TOPAZ
  1093.     TOPAZ  Let's get together Monday at 1pm.
  1094.     TOPAZ  .
  1095.     RED    250 OK
  1096.     TOPAZ  QUIT
  1097.     RED    221 RED.RUTGERS.EDU Service closing transmission channel
  1098.  
  1099. First, note that commands all use normal text.  This is typical of the
  1100. Internet  standards.    Many  of  the  protocols  use  standard  ASCII
  1101. commands.  This makes it easy  to  watch  what  is  going  on  and  to
  1102. diagnose  problems.  For example, the mail program keeps a log of each
  1103. conversation.  If something goes wrong, the log  file  can  simply  be
  1104. mailed  to  the  postmaster.  Since it is normal text, he can see what
  1105. was going on.  It also allows a human to interact  directly  with  the
  1106. mail  server,  for  testing.  (Some newer protocols are complex enough
  1107. that this is not practical.  The commands would have to have a  syntax
  1108. that would require a significant parser.  Thus there is a tendency for
  1109. newer protocols to use binary formats.  Generally they are  structured
  1110. like  C or Pascal record structures.)  Second, note that the responses
  1111. all begin with numbers.  This is also typical of  Internet  protocols.
  1112. The  allowable  responses  are  defined  in the protocol.  The numbers
  1113. allow the user program to respond unambiguously.    The  rest  of  the
  1114. response  is  text,  which is normally for use by any human who may be
  1115. watching or looking at a log.  It has no effect on  the  operation  of
  1116. the  programs.  (However there is one point at which the protocol uses
  1117. part of the text of the response.)   The  commands  themselves  simply
  1118. allow  the  mail  program  on  one  end  to  tell  the mail server the
  1119.                                   16
  1120.  
  1121.  
  1122.  
  1123. information it needs to know in order to deliver the message.  In this
  1124. case,  the  mail  server  could  get the information by looking at the
  1125. message itself.  But for more complex cases, that would not  be  safe.
  1126. Every  session  must  begin  with  a HELO, which gives the name of the
  1127. system that initiated the connection.  Then the sender and  recipients
  1128. are specified.  (There can be more than one RCPT command, if there are
  1129. several recipients.)  Finally the data itself is sent.  Note that  the
  1130. text  of the message is terminated by a line containing just a period.
  1131. (If such a line appears in the message, the period is doubled.)  After
  1132. the  message  is  accepted,  the  sender  can send another message, or
  1133. terminate the session as in the example above.
  1134.  
  1135. Generally, there is a pattern to the response numbers.   The  protocol
  1136. defines  the  specific set of responses that can be sent as answers to
  1137. any given command.  However programs that don't want to  analyze  them
  1138. in  detail  can  just  look at the first digit.  In general, responses
  1139. that begin with a 2  indicate  success.    Those  that  begin  with  3
  1140. indicate  that some further action is needed, as shown above.  4 and 5
  1141. indicate errors.  4 is a "temporary" error, such as  a  disk  filling.
  1142. The  message should be saved, and tried again later.  5 is a permanent
  1143. error, such as a  non-existent  recipient.    The  message  should  be
  1144. returned to the sender with an error message.
  1145.  
  1146. (For  more  details about the protocols mentioned in this section, see
  1147. RFC's 821/822 for mail, RFC 959 for file transfer, and  RFC's  854/855
  1148. for  remote  logins.  For the well-known port numbers, see the current
  1149. edition of Assigned Numbers, and possibly RFC 814.)
  1150.  
  1151.  
  1152.  
  1153. 4. Protocols other than TCP: UDP and ICMP
  1154.  
  1155.  
  1156. So far, we have described only connections that use TCP.  Recall  that
  1157. TCP  is  responsible  for  breaking  up  messages  into datagrams, and
  1158. reassembling them properly.  However in  many  applications,  we  have
  1159. messages  that  will  always  fit in a single datagram.  An example is
  1160. name lookup.  When a user attempts to make  a  connection  to  another
  1161. system,  he  will  generally  specify  the system by name, rather than
  1162. Internet address.  His system has to translate that name to an address
  1163. before  it  can  do  anything.  Generally, only a few systems have the
  1164. database used to translate names to addresses.  So the  user's  system
  1165. will want to send a query to one of the systems that has the database.
  1166. This query is going to be very short.  It will certainly  fit  in  one
  1167. datagram.    So  will the answer.  Thus it seems silly to use TCP.  Of
  1168. course TCP does more than just break things up  into  datagrams.    It
  1169. also  makes  sure  that  the  data  arrives, resending datagrams where
  1170. necessary.  But for a question that fits  in  a  single  datagram,  we
  1171. don't  need  all the complexity of TCP to do this.  If we don't get an
  1172. answer after a few seconds, we can just ask again.   For  applications
  1173. like this, there are alternatives to TCP.
  1174.  
  1175. The most common alternative is UDP ("user datagram protocol").  UDP is
  1176. designed for applications where you don't need  to  put  sequences  of
  1177. datagrams  together.  It fits into the system much like TCP.  There is
  1178.                                   17
  1179.  
  1180.  
  1181.  
  1182. a UDP header.  The network software puts the UDP header on  the  front
  1183. of  your  data, just as it would put a TCP header on the front of your
  1184. data.  Then UDP sends the data  to  IP,  which  adds  the  IP  header,
  1185. putting  UDP's  protocol number in the protocol field instead of TCP's
  1186. protocol number.  However UDP doesn't do as much  as  TCP  does.    It
  1187. doesn't  split data into multiple datagrams.  It doesn't keep track of
  1188. what it has sent so it can resend if necessary.  About  all  that  UDP
  1189. provides  is  port  numbers,  so  that several programs can use UDP at
  1190. once.  UDP port numbers are used just like TCP port  numbers.    There
  1191. are  well-known  port numbers for servers that use UDP.  Note that the
  1192. UDP header is shorter than a TCP header.   It  still  has  source  and
  1193. destination  port  numbers,  and  a checksum, but that's about it.  No
  1194. sequence number, since it is not needed.  UDP is used by the protocols
  1195. that  handle  name  lookups (see IEN 116, RFC 882, and RFC 883), and a
  1196. number of similar protocols.
  1197.  
  1198. Another  alternative  protocol  is  ICMP  ("Internet  control  message
  1199. protocol").    ICMP  is  used  for  error messages, and other messages
  1200. intended for the TCP/IP software itself, rather  than  any  particular
  1201. user  program.  For example, if you attempt to connect to a host, your
  1202. system may get back an ICMP message saying "host unreachable".    ICMP
  1203. can  also be used to find out some information about the network.  See
  1204. RFC 792 for details of ICMP.  ICMP is  similar  to  UDP,  in  that  it
  1205. handles messages that fit in one datagram.  However it is even simpler
  1206. than UDP.  It doesn't even have port numbers in its header.  Since all
  1207. ICMP  messages are interpreted by the network software itself, no port
  1208. numbers are needed to say where a ICMP message is supposed to go.
  1209.  
  1210.  
  1211.  
  1212. 5. Keeping track of names and information: the domain system
  1213.  
  1214.  
  1215. As we indicated earlier, the network software generally needs a 32-bit
  1216. Internet  address  in  order  to open a connection or send a datagram.
  1217. However users prefer to deal with computer names rather than  numbers.
  1218. Thus  there  is  a database that allows the software to look up a name
  1219. and find the corresponding number.  When the Internet was small,  this
  1220. was  easy.  Each system would have a file that listed all of the other
  1221. systems, giving both their name and number.  There are  now  too  many
  1222. computers  for  this  approach to be practical.  Thus these files have
  1223. been replaced by a set of name servers that keep track of  host  names
  1224. and  the corresponding Internet addresses.  (In fact these servers are
  1225. somewhat more general than that.  This is just one kind of information
  1226. stored in the domain system.)  Note that a set of interlocking servers
  1227. are used, rather than a single central one.  There  are  now  so  many
  1228. different  institutions  connected  to  the  Internet that it would be
  1229. impractical for them to  notify  a  central  authority  whenever  they
  1230. installed  or moved a computer.  Thus naming authority is delegated to
  1231. individual institutions.  The name servers form a tree,  corresponding
  1232. to  institutional  structure.    The names themselves follow a similar
  1233. structure.  A typical example is the name BORAX.LCS.MIT.EDU.  This  is
  1234. a  computer  at  the Laboratory for Computer Science (LCS) at MIT.  In
  1235. order to find its Internet address,  you  might  potentially  have  to
  1236. consult  4  different  servers.  First, you would ask a central server
  1237.                                   18
  1238.  
  1239.  
  1240.  
  1241. (called the root) where the EDU server is.  EDU is a server that keeps
  1242. track of educational institutions.  The root server would give you the
  1243. names and Internet addresses of several servers for EDU.   (There  are
  1244. several  servers  at  each  level,  to allow for the possibly that one
  1245. might be down.)  You would then ask EDU where the server for  MIT  is.
  1246. Again,  it  would  give  you  names  and Internet addresses of several
  1247. servers for MIT.  Generally, not all of those servers would be at MIT,
  1248. to  allow for the possibility of a general power failure at MIT.  Then
  1249. you would ask MIT where the server for LCS is, and finally  you  would
  1250. ask one of the LCS servers about BORAX.  The final result would be the
  1251. Internet address for BORAX.LCS.MIT.EDU.    Each  of  these  levels  is
  1252. referred  to  as  a  "domain".  The entire name, BORAX.LCS.MIT.EDU, is
  1253. called a "domain name".    (So  are  the  names  of  the  higher-level
  1254. domains, such as LCS.MIT.EDU, MIT.EDU, and EDU.)
  1255.  
  1256. Fortunately,  you  don't really have to go through all of this most of
  1257. the time.  First of all, the root name servers also happen to  be  the
  1258. name  servers  for  the  top-level domains such as EDU.  Thus a single
  1259. query to a root  server  will  get  you  to  MIT.    Second,  software
  1260. generally  remembers answers that it got before.  So once we look up a
  1261. name at LCS.MIT.EDU, our software remembers where to find servers  for
  1262. LCS.MIT.EDU,  MIT.EDU,  and EDU.  It also remembers the translation of
  1263. BORAX.LCS.MIT.EDU.  Each of these pieces of information has a "time to
  1264. live"  associated with it.  Typically this is a few days.  After that,
  1265. the information expires and has to be looked up again.    This  allows
  1266. institutions to change things.
  1267.  
  1268. The  domain  system  is not limited to finding out Internet addresses.
  1269. Each domain name is a node in a database.  The node can  have  records
  1270. that  define  a number of different properties.  Examples are Internet
  1271. address, computer type, and a list of services provided by a computer.
  1272. A  program  can  ask  for  a  specific  piece  of  information, or all
  1273. information about a given name.  It is possible  for  a  node  in  the
  1274. database  to  be  marked as an "alias" (or nickname) for another node.
  1275. It is also possible to use the  domain  system  to  store  information
  1276. about users, mailing lists, or other objects.
  1277.  
  1278. There  is  an  Internet  standard  defining  the  operation  of  these
  1279. databases, as well as the protocols used  to  make  queries  of  them.
  1280. Every  network utility has to be able to make such queries, since this
  1281. is now the official way to evaluate host names.   Generally  utilities
  1282. will talk to a server on their own system.  This server will take care
  1283. of contacting the other servers for them.  This keeps down the  amount
  1284. of code that has to be in each application program.
  1285.  
  1286. The  domain  system  is  particularly  important for handling computer
  1287. mail.  There are entry types to define what computer handles mail  for
  1288. a  given  name, to specify where an individual is to receive mail, and
  1289. to define mailing lists.
  1290.  
  1291. (See RFC's 882, 883, and 973 for specifications of the domain  system.
  1292. RFC 974 defines the use of the domain system in sending mail.)
  1293.  
  1294.  
  1295.  
  1296.                                   19
  1297.  
  1298.  
  1299.  
  1300. 6. Routing
  1301.  
  1302.  
  1303. The   description  above  indicated  that  the  IP  implementation  is
  1304. responsible for getting datagrams to the destination indicated by  the
  1305. destination address, but little was said about how this would be done.
  1306. The task of finding how to  get  a  datagram  to  its  destination  is
  1307. referred to as "routing".  In fact many of the details depend upon the
  1308. particular implementation.  However some general things can be said.
  1309.  
  1310. First, it is necessary to understand the model on which IP  is  based.
  1311. IP assumes that a system is attached to some local network.  We assume
  1312. that the system can send datagrams to any  other  system  on  its  own
  1313. network.    (In  the  case  of  Ethernet, it simply finds the Ethernet
  1314. address of the destination system, and puts the datagram  out  on  the
  1315. Ethernet.)    The  problem  comes  when  a  system  is asked to send a
  1316. datagram to a system on a different network.  This problem is  handled
  1317. by  gateways.   A gateway is a system that connects a network with one
  1318. or more other networks.  Gateways  are  often  normal  computers  that
  1319. happen  to have more than one network interface.  For example, we have
  1320. a Unix machine that has two different Ethernet interfaces.  Thus it is
  1321. connected  to networks 128.6.4 and 128.6.3.  This machine can act as a
  1322. gateway between those two networks.  The software on that machine must
  1323. be  set  up  so that it will forward datagrams from one network to the
  1324. other.  That is, if a machine on network 128.6.4 sends a  datagram  to
  1325. the  gateway,  and  the  datagram is addressed to a machine on network
  1326. 128.6.3, the gateway will forward the  datagram  to  the  destination.
  1327. Major communications centers often have gateways that connect a number
  1328. of different  networks.    (In  many  cases,  special-purpose  gateway
  1329. systems provide better performance or reliability than general-purpose
  1330. systems acting as gateways.  A number of vendors sell such systems.)
  1331.  
  1332. Routing in IP is  based  entirely  upon  the  network  number  of  the
  1333. destination  address.    Each computer has a table of network numbers.
  1334. For each network number, a gateway is listed.  This is the gateway  to
  1335. be used to get to that network.  Note that the gateway doesn't have to
  1336. connect directly to the network.  It just has to be the best place  to
  1337. go  to  get there.  For example at Rutgers, our interface to NSFnet is
  1338. at the John von Neuman Supercomputer Center (JvNC). Our connection  to
  1339. JvNC  is  via  a  high-speed  serial line connected to a gateway whose
  1340. address is 128.6.3.12.  Systems on net 128.6.3 will list 128.6.3.12 as
  1341. the  gateway  for  many  off-campus  networks.  However systems on net
  1342. 128.6.4 will list 128.6.4.1 as the gateway to  those  same  off-campus
  1343. networks.    128.6.4.1  is  the  gateway  between networks 128.6.4 and
  1344. 128.6.3, so it is the first step in getting to JvNC.
  1345.  
  1346. When a computer wants to send a datagram, it first checks  to  see  if
  1347. the  destination address is on the system's own local network.  If so,
  1348. the datagram can be sent directly.  Otherwise, the system  expects  to
  1349. find an entry for the network that the destination address is on.  The
  1350. datagram is sent to the gateway listed in that entry.  This table  can
  1351. get quite big.  For example, the Internet now includes several hundred
  1352. individual networks.  Thus various strategies have been  developed  to
  1353. reduce  the size of the routing table.  One strategy is to depend upon
  1354. "default routes".  Often, there is only one gateway out of a  network.
  1355.                                   20
  1356.  
  1357.  
  1358.  
  1359. This  gateway might connect a local Ethernet to a campus-wide backbone
  1360. network.  In that case, we don't need to have  a  separate  entry  for
  1361. every  network  in  the  world.    We  simply define that gateway as a
  1362. "default".  When no specific  route  is  found  for  a  datagram,  the
  1363. datagram  is  sent to the default gateway.  A default gateway can even
  1364. be used when there are several gateways  on  a  network.    There  are
  1365. provisions  for  gateways  to  send a message saying "I'm not the best
  1366. gateway -- use this one instead."  (The message is sent via ICMP.  See
  1367. RFC  792.)  Most network software is designed to use these messages to
  1368. add entries to their routing tables.  Suppose network 128.6.4 has  two
  1369. gateways, 128.6.4.59 and 128.6.4.1.  128.6.4.59 leads to several other
  1370. internal Rutgers networks.  128.6.4.1 leads indirectly to the  NSFnet.
  1371. Suppose  we  set  128.6.4.59  as  a default gateway, and have no other
  1372. routing table entries.  Now what  happens  when  we  need  to  send  a
  1373. datagram  to  MIT?    MIT  is  network 18.  Since we have no entry for
  1374. network 18, the datagram will be sent to the default, 128.6.4.59.   As
  1375. it  happens,  this  gateway  is the wrong one.  So it will forward the
  1376. datagram to 128.6.4.1.  But it will also send back an error saying  in
  1377. effect: "to get to network 18, use 128.6.4.1".  Our software will then
  1378. add an entry to the routing table.  Any future datagrams to  MIT  will
  1379. then  go  directly to 128.6.4.1.  (The error message is sent using the
  1380. ICMP protocol.  The message type is called "ICMP redirect.")
  1381.  
  1382. Most IP experts recommend that individual computers should not try  to
  1383. keep  track  of  the  entire network.  Instead, they should start with
  1384. default gateways, and let the gateways tell them the routes,  as  just
  1385. described.   However this doesn't say how the gateways should find out
  1386. about the routes.  The gateways can't depend upon this strategy.  They
  1387. have  to  have fairly complete routing tables.  For this, some sort of
  1388. routing protocol is needed.  A routing protocol is simply a  technique
  1389. for  the  gateways  to  find each other, and keep up to date about the
  1390. best way to get to every network.   RFC  1009  contains  a  review  of
  1391. gateway  design  and  routing.    However rip.doc is probably a better
  1392. introduction to the subject.  It contains some tutorial material,  and
  1393. a detailed description of the most commonly-used routing protocol.
  1394.  
  1395.  
  1396.  
  1397. 7. Details about Internet addresses: subnets and broadcasting
  1398.  
  1399.  
  1400. As  indicated earlier, Internet addresses are 32-bit numbers, normally
  1401. written as 4 octets (in decimal), e.g. 128.6.4.7.  There are  actually
  1402. 3  different types of address.  The problem is that the address has to
  1403. indicate both the network and the host within the  network.    It  was
  1404. felt  that  eventually  there would be lots of networks.  Many of them
  1405. would be small, but probably 24 bits would be needed to represent  all
  1406. the  IP  networks.  It was also felt that some very big networks might
  1407. need 24 bits to represent all of their hosts.  This would seem to lead
  1408. to  48  bit  addresses.  But the designers really wanted to use 32 bit
  1409. addresses.  So they adopted a kludge.  The assumption is that most  of
  1410. the  networks will be small.  So they set up three different ranges of
  1411. address.  Addresses beginning with 1 to 126 use only the  first  octet
  1412. for  the network number.  The other three octets are available for the
  1413. host number.  Thus 24 bits are available for hosts.  These numbers are
  1414.                                   21
  1415.  
  1416.  
  1417.  
  1418. used  for large networks.  But there can only be 126 of these very big
  1419. networks.  The Arpanet is one, and there are a  few  large  commercial
  1420. networks.    But  few  normal organizations get one of these "class A"
  1421. addresses.  For normal large organizations, "class  B"  addresses  are
  1422. used.    Class  B  addresses  use the first two octets for the network
  1423. number.  Thus network numbers are 128.1 through 191.254.  (We avoid  0
  1424. and  255,  for  reasons  that  we  see below.  We also avoid addresses
  1425. beginning with 127, because that is used by some systems  for  special
  1426. purposes.)    The  last  two  octets  are available for host addesses,
  1427. giving 16 bits of host address.   This  allows  for  64516  computers,
  1428. which should be enough for most organizations.  (It is possible to get
  1429. more than one class B address, if you run  out.)    Finally,  class  C
  1430. addresses  use  three  octets,  in  the  range 192.1.1 to 223.254.254.
  1431. These allow only 254 hosts on each network, but there can be  lots  of
  1432. these  networks.   Addresses above 223 are reserved for future use, as
  1433. class D and E (which are currently not defined).
  1434.  
  1435. Many large organizations find it convenient to  divide  their  network
  1436. number into "subnets".  For example, Rutgers has been assigned a class
  1437. B address, 128.6.  We find it convenient to use the third octet of the
  1438. address to indicate which Ethernet a host is on.  This division has no
  1439. significance outside of Rutgers.  A computer  at  another  institution
  1440. would treat all datagrams addressed to 128.6 the same way.  They would
  1441. not look at the third octet of the address.   Thus  computers  outside
  1442. Rutgers  would  not have different routes for 128.6.4 or 128.6.5.  But
  1443. inside Rutgers, we treat 128.6.4 and 128.6.5 as separate networks.  In
  1444. effect, gateways inside Rutgers have separate entries for each Rutgers
  1445. subnet, whereas gateways outside  Rutgers  just  have  one  entry  for
  1446. 128.6.  Note  that  we  could  do  exactly  the  same thing by using a
  1447. separate class C address for each Ethernet.   As  far  as  Rutgers  is
  1448. concerned,  it  would be just as convenient for us to have a number of
  1449. class C addresses.  However using class C addresses would make  things
  1450. inconvenient for the rest of the world.  Every institution that wanted
  1451. to talk to us would have to have a separate entry for each one of  our
  1452. networks.   If every institution did this, there would be far too many
  1453. networks for any reasonable gateway to keep track of.  By  subdividing
  1454. a  class B network, we hide our internal structure from everyone else,
  1455. and  save  them  trouble.    This  subnet  strategy  requires  special
  1456. provisions in the network software.  It is described in RFC 950.
  1457.  
  1458. 0  and  255  have  special  meanings.  0 is reserved for machines that
  1459. don't know their address.  In certain circumstances it is possible for
  1460. a  machine not to know the number of the network it is on, or even its
  1461. own host address.  For example, 0.0.0.23 would be a machine that  knew
  1462. it was host number 23, but didn't know on what network.
  1463.  
  1464. 255  is  used for "broadcast".  A broadcast is a message that you want
  1465. every system on the network to see.    Broadcasts  are  used  in  some
  1466. situations  where you don't know who to talk to.  For example, suppose
  1467. you need to look  up  a  host  name  and  get  its  Internet  address.
  1468. Sometimes  you  don't know the address of the nearest name server.  In
  1469. that case, you might send the request as a broadcast.  There are  also
  1470. cases  where a number of systems are interested in information.  It is
  1471. then less expensive to send a single broadcast than to send  datagrams
  1472. individually  to  each host that is interested in the information.  In
  1473.                                   22
  1474.  
  1475.  
  1476.  
  1477. order to send a broadcast, you use an address that is  made  by  using
  1478. your  network  address, with all ones in the part of the address where
  1479. the host number goes.  For example, if you are on network 128.6.4, you
  1480. would   use   128.6.4.255  for  broadcasts.    How  this  is  actually
  1481. implemented depends upon the medium.   It  is  not  possible  to  send
  1482. broadcasts  on the Arpanet, or on point to point lines.  However it is
  1483. possible on an Ethernet.  If you use an Ethernet address with all  its
  1484. bits  on (all ones), every machine on the Ethernet is supposed to look
  1485. at that datagram.
  1486.  
  1487. Although the official broadcast address for  network  128.6.4  is  now
  1488. 128.6.4.255,  there  are  some  other addresses that may be treated as
  1489. broadcasts by certain implementations.  For convenience, the  standard
  1490. also  allows  255.255.255.255 to be used.  This refers to all hosts on
  1491. the local network.  It is often simpler to use 255.255.255.255 instead
  1492. of  finding out the network number for the local network and forming a
  1493. broadcast address such as 128.6.4.255.   In  addition,  certain  older
  1494. implementations  may  use  0  instead  of  255  to  form the broadcast
  1495. address.    Such  implementations  would  use  128.6.4.0  instead   of
  1496. 128.6.4.255  as  the  broadcast  address on network 128.6.4.  Finally,
  1497. certain older implementations may not understand about subnets.   Thus
  1498. they consider the network number to be 128.6.  In that case, they will
  1499. assume a broadcast address  of  128.6.255.255  or  128.6.0.0.    Until
  1500. support  for  broadcasts is implemented properly, it can be a somewhat
  1501. dangerous feature to use.
  1502.  
  1503. Because 0 and 255 are used for unknown and broadcast addresses, normal
  1504. hosts  should never be given addresses containing 0 or 255.  Addresses
  1505. should never begin with 0, 127, or any number above  223.    Addresses
  1506. violating these rules are sometimes referred to as "Martians", because
  1507. of rumors that the Central University of Mars is using network 225.
  1508.  
  1509.  
  1510.  
  1511. 8. Datagram fragmentation and reassembly
  1512.  
  1513.  
  1514. TCP/IP is designed for use  with  many  different  kinds  of  network.
  1515. Unfortunately,  network  designers  do not agree about how big packets
  1516. can be.  Ethernet packets can be 1500 octets long.    Arpanet  packets
  1517. have  a  maximum  of around 1000 octets.  Some very fast networks have
  1518. much larger packet sizes.  At first, you might think  that  IP  should
  1519. simply  settle  on  the  smallest  possible size.  Unfortunately, this
  1520. would cause serious performance problems.    When  transferring  large
  1521. files, big packets are far more efficient than small ones.  So we want
  1522. to be able to use the largest packet size possible.  But we also  want
  1523. to  be  able  to  handle  networks  with  small limits.  There are two
  1524. provisions for this.  First, TCP has the ability to "negotiate"  about
  1525. datagram  size.  When a TCP connection first opens, both ends can send
  1526. the maximum datagram size they can  handle.    The  smaller  of  these
  1527. numbers  is  used  for  the  rest  of the connection.  This allows two
  1528. implementations that can handle big datagrams to use  them,  but  also
  1529. lets  them  talk  to  implementations that can't handle them.  However
  1530. this doesn't completely solve the problem.  The most  serious  problem
  1531. is  that the two ends don't necessarily know about all of the steps in
  1532.                                   23
  1533.  
  1534.  
  1535.  
  1536. between.  For example, when sending data between Rutgers and Berkeley,
  1537. it is likely that both computers will be on Ethernets.  Thus they will
  1538. both  be  prepared  to  handle  1500-octet  datagrams.    However  the
  1539. connection will at some point end up going over the Arpanet.  It can't
  1540. handle packets of that size.  For this reason, there are provisions to
  1541. split   datagrams   up   into   pieces.    (This  is  referred  to  as
  1542. "fragmentation".)  The IP header  contains  fields  indicating  the  a
  1543. datagram  has  been split, and enough information to let the pieces be
  1544. put back together.  If a gateway connects an Ethernet to the  Arpanet,
  1545. it must be prepared to take 1500-octet Ethernet packets and split them
  1546. into pieces that will fit on the Arpanet.    Furthermore,  every  host
  1547. implementation  of  TCP/IP  must  be prepared to accept pieces and put
  1548. them back together.  This is referred to as "reassembly".
  1549.  
  1550. TCP/IP implementations differ in the approach they take to deciding on
  1551. datagram  size.    It  is  fairly  common  for  implementations to use
  1552. 576-byte datagrams whenever they can't verify that the entire path  is
  1553. able  to  handle larger packets.  This rather conservative strategy is
  1554. used because of the number of implementations with bugs in the code to
  1555. reassemble  fragments.    Implementors  often try to avoid ever having
  1556. fragmentation occur.  Different implementors take different approaches
  1557. to  deciding  when  it  is safe to use large datagrams.  Some use them
  1558. only for the local network.  Others will use them for any  network  on
  1559. the   same   campus.    576  bytes  is  a  "safe"  size,  which  every
  1560. implementation must support.
  1561.  
  1562.  
  1563.  
  1564. 9. Ethernet encapsulation: ARP
  1565.  
  1566.  
  1567. There was a brief discussion earlier about what IP datagrams look like
  1568. on  an  Ethernet.    The  discussion  showed  the  Ethernet header and
  1569. checksum.  However it left one hole: It didn't say how to  figure  out
  1570. what Ethernet address to use when you want to talk to a given Internet
  1571. address.  In fact, there is a separate protocol for this,  called  ARP
  1572. ("address  resolution protocol").  (Note by the way that ARP is not an
  1573. IP protocol.  That is, the ARP datagrams  do  not  have  IP  headers.)
  1574. Suppose  you  are  on  system  128.6.4.194  and you want to connect to
  1575. system 128.6.4.7.  Your system will first verify that 128.6.4.7 is  on
  1576. the  same network, so it can talk directly via Ethernet.  Then it will
  1577. look up 128.6.4.7 in its ARP table, to see if  it  already  knows  the
  1578. Ethernet  address.    If  so, it will stick on an Ethernet header, and
  1579. send the packet.  But suppose this system is not  in  the  ARP  table.
  1580. There  is  no  way  to  send the packet, because you need the Ethernet
  1581. address.  So it  uses  the  ARP  protocol  to  send  an  ARP  request.
  1582. Essentially  an  ARP  request  says  "I  need the Ethernet address for
  1583. 128.6.4.7".  Every system listens to ARP requests.  When a system sees
  1584. an  ARP  request  for itself, it is required to respond.  So 128.6.4.7
  1585. will see the request, and will respond with an  ARP  reply  saying  in
  1586. effect "128.6.4.7 is 8:0:20:1:56:34".  (Recall that Ethernet addresses
  1587. are 48 bits.  This is 6 octets.  Ethernet addresses are conventionally
  1588. shown  in  hex,  using  the punctuation shown.)  Your system will save
  1589. this information in its ARP table, so future packets will go directly.
  1590. Most  systems  treat the ARP table as a cache, and clear entries in it
  1591.                                   24
  1592.  
  1593.  
  1594.  
  1595. if they have not been used in a certain period of time.
  1596.  
  1597. Note by the way that ARP requests must be sent as "broadcasts".  There
  1598. is  no  way  that  an  ARP  request  can be sent directly to the right
  1599. system.  After all, the whole reason for sending  an  ARP  request  is
  1600. that  you  don't know the Ethernet address.  So an Ethernet address of
  1601. all ones is  used,  i.e.  ff:ff:ff:ff:ff:ff.    By  convention,  every
  1602. machine  on  the Ethernet is required to pay attention to packets with
  1603. this as an address.  So every system sees every ARP  requests.    They
  1604. all  look to see whether the request is for their own address.  If so,
  1605. they respond.  If not, they could just ignore it.   (Some  hosts  will
  1606. use  ARP  requests  to update their knowledge about other hosts on the
  1607. network, even if the request isn't for them.)  Note that packets whose
  1608. IP  address  indicates broadcast (e.g. 255.255.255.255 or 128.6.4.255)
  1609. are also sent with an Ethernet address that is all ones.
  1610.  
  1611.  
  1612.  
  1613. 10. Getting more information
  1614.  
  1615.  
  1616. This directory contains  documents  describing  the  major  protocols.
  1617. There  are literally hundreds of documents, so we have chosen the ones
  1618. that seem most important.  Internet standards are called RFC's.    RFC
  1619. stands  for  Request  for  Comment.   A proposed standard is initially
  1620. issued as a proposal, and given an RFC number.   When  it  is  finally
  1621. accepted,  it is added to Official Internet Protocols, but it is still
  1622. referred to by the RFC number.   We  have  also  included  two  IEN's.
  1623. (IEN's  used  to  be  a  separate  classification  for  more  informal
  1624. documents.  This classification no longer exists -- RFC's are now used
  1625. for  all  official  Internet documents, and a mailing list is used for
  1626. more informal reports.)  The convention is that  whenever  an  RFC  is
  1627. revised, the revised version gets a new number.  This is fine for most
  1628. purposes, but it causes problems with two documents: Assigned  Numbers
  1629. and  Official  Internet  Protocols.  These documents are being revised
  1630. all the time, so the RFC number keeps changing.  You will have to look
  1631. in rfc-index.txt to find the number of the latest edition.  Anyone who
  1632. is seriously interested in TCP/IP should read the  RFC  describing  IP
  1633. (791).    RFC 1009 is also useful.  It is a specification for gateways
  1634. to be used by NSFnet.  As such, it contains an overview of  a  lot  of
  1635. the  TCP/IP technology.  You should probably also read the description
  1636. of at least one of the application protocols, just to get a  feel  for
  1637. the  way  things  work.    Mail is probably a good one (821/822).  TCP
  1638. (793) is of course a very basic specification.  However  the  spec  is
  1639. fairly  complex,  so  you should only read this when you have the time
  1640. and patience to think about it carefully.  Fortunately, the author  of
  1641. the  major  RFC's  (Jon Postel) is a very good writer.  The TCP RFC is
  1642. far easier to read than you would expect, given the complexity of what
  1643. it  is  describing.    You  can  look at the other RFC's as you become
  1644. curious about their subject matter.
  1645.  
  1646. Here is a list of the documents you are more likely to want:
  1647.  
  1648.      rfc-index list of all RFC's
  1649.  
  1650.                                   25
  1651.  
  1652.  
  1653.  
  1654.      rfc1012   somewhat fuller list of all RFC's
  1655.  
  1656.      rfc1011   Official Protocols.  It's useful to scan  this  to  see
  1657.                what tasks protocols have been built for.  This defines
  1658.                which  RFC's  are  actual  standards,  as  opposed   to
  1659.                requests for comments.
  1660.  
  1661.      rfc1010   Assigned  Numbers.  If you are working with TCP/IP, you
  1662.                will probably want a hardcopy of this as  a  reference.
  1663.                It's  not  very  exciting  to  read.   It lists all the
  1664.                offically defined well-known ports and  lots  of  other
  1665.                things.
  1666.  
  1667.      rfc1009   NSFnet  gateway  specifications.  A good overview of IP
  1668.                routing and gateway technology.
  1669.  
  1670.      rfc1001/2 netBIOS: networking for PC's
  1671.  
  1672.      rfc973    update on domains
  1673.  
  1674.      rfc959    FTP (file transfer)
  1675.  
  1676.      rfc950    subnets
  1677.  
  1678.      rfc937    POP2: protocol for reading mail on PC's
  1679.  
  1680.      rfc894    how IP is to be put on Ethernet, see also rfc825
  1681.  
  1682.      rfc882/3  domains (the database used to go  from  host  names  to
  1683.                Internet  address  and back -- also used to handle UUCP
  1684.                these days).  See also rfc973
  1685.  
  1686.      rfc854/5  telnet - protocol for remote logins
  1687.  
  1688.      rfc826    ARP - protocol for finding out Ethernet addresses
  1689.  
  1690.      rfc821/2  mail
  1691.  
  1692.      rfc814    names and ports - general  concepts  behind  well-known
  1693.                ports
  1694.  
  1695.      rfc793    TCP
  1696.  
  1697.      rfc792    ICMP
  1698.  
  1699.      rfc791    IP
  1700.  
  1701.      rfc768    UDP
  1702.  
  1703.      rip.doc   details of the most commonly-used routing protocol
  1704.  
  1705.      ien-116   old  name  server  (still  needed  by  several kinds of
  1706.                system)
  1707.  
  1708.      ien-48    the  Catenet  model,   general   description   of   the
  1709.                                   26
  1710.  
  1711.  
  1712.  
  1713.                philosophy behind TCP/IP 
  1714.  
  1715. The following documents are somewhat more specialized.
  1716.  
  1717.      rfc813    window and acknowledgement strategies in TCP
  1718.  
  1719.      rfc815    datagram reassembly techniques
  1720.  
  1721.      rfc816    fault isolation and resolution techniques
  1722.  
  1723.      rfc817    modularity and efficiency in implementation
  1724.  
  1725.      rfc879    the maximum segment size option in TCP
  1726.  
  1727.      rfc896    congestion control
  1728.  
  1729.      rfc827,888,904,975,985
  1730.                EGP and related issues 
  1731.  
  1732. To those of you who may be reading this document remotely  instead  of
  1733. at  Rutgers:  The  most  important  RFC's  have  been collected into a
  1734. three-volume set, the DDN Protocol Handbook.  It is available from the
  1735. DDN  Network  Information  Center,  SRI  International, 333 Ravenswood
  1736. Avenue, Menlo Park, California 94025 (telephone: 800-235-3155).    You
  1737. should  be able to get them via anonymous FTP from sri-nic.arpa.  File
  1738. names are:  
  1739.  
  1740.   RFC's:
  1741.     rfc:rfc-index.txt
  1742.     rfc:rfcxxx.txt
  1743.   IEN's:
  1744.     ien:ien-index.txt
  1745.     ien:ien-xxx.txt
  1746.  
  1747. rip.doc is available  by  anonymous  FTP  from  topaz.rutgers.edu,  as
  1748. /pub/tcp-ip-docs/rip.doc.
  1749.  
  1750. Sites with access to UUCP but not FTP may be able to retreive them via
  1751. UUCP from UUCP host rutgers.  The file names would be 
  1752.  
  1753.   RFC's:
  1754.     /topaz/pub/pub/tcp-ip-docs/rfc-index.txt
  1755.     /topaz/pub/pub/tcp-ip-docs/rfcxxx.txt
  1756.   IEN's:
  1757.     /topaz/pub/pub/tcp-ip-docs/ien-index.txt
  1758.     /topaz/pub/pub/tcp-ip-docs/ien-xxx.txt
  1759.   /topaz/pub/pub/tcp-ip-docs/rip.doc
  1760.  
  1761. Note that SRI-NIC has the entire set of RFC's and IEN's,  but  rutgers
  1762. and topaz have only those specifically mentioned above.
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.                                   27
  1769.  
  1770.